﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFrom2
{
    public partial class Update : Form
    {
        public Update()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            var Id = this.textBox1.Text;
            var name = this.textBox2.Text;
            var pwd = this.textBox3.Text;
            var res = MessageBox.Show("是否保存？", "提示", MessageBoxButtons.OKCancel);
            if (res > 0)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    var re = string.Format("update Articles set Title='{0}',Author='{1}' where id='{2}'", name, pwd,Id );
                    var dt = Dbhelper .AddOrEdiOrdeletetSave (re);
                    if (dt == 1)
                    {
                        MessageBox.Show("更新成功", "提示");
                        this.DialogResult = DialogResult.Yes;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("更新失败", "提示");
                    }
                }
            }
        }

        
    }
}
